package com.t11;
import typeinfo.pets.*;
import java.util.*;
import static net.mindview.util.Print.*;

/**
 * Created by xuyiwei on 2018/7/22.
 */
public class SimpleIteration {
    public static void main(String[] args) {
        List<Pet> pets = Pets.arrayList(12);
        Iterator<Pet> it = pets.iterator();
//        while (it.hasNext()){
//            Pet p = it.next();
//            System.out.println(p.id()+" : "+p+" ");
//        }
//        System.out.println();
        for(Pet pet:pets){
            System.out.println(pet.id()+" : "+pet+" ");
        }
        System.out.println();
        while (it.hasNext()){
            Pet p = it.next();
            if(p.id()==3){
                //如果需要删除list集合里面的元素 用迭代器的方式更加的合适
                it.remove();
            }
        }
        System.out.println(pets);

    }
}
